import type { App, Directive } from 'vue'
import { focus } from './focus'
import { numIncrease } from './numIncrease'
import { debounce } from './debounce'
import { permission } from './permission'
import { copyText } from './copyText'
import { slideIn } from './slideIn'
import { mouseDirection } from './mouseDirection'
import { specialEffects } from './wrapper'
import { tableAutoScroll } from './tableAutoScroll'

interface IDirectives {
  [key: string]: Directive
}

const directives: IDirectives = {
  focus,
  numIncrease,
  debounce,
  permission,
  copyText,
  slideIn,
  mouseDirection,
  specialEffects,
  tableAutoScroll
}

/** 注册全部指令；方便app注册 */
export default function registerDirectives(app: App) {
  // 遍历指令对象中的所有键
  Object.keys(directives).forEach((key) => {
    // 将每个键对应的指令注册到app中
    app.directive(key, directives[key])
  })
}
